package iface.aplicativo.negocio.entidade;

import iface.arquitetura.entidade.Entidade;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
@Table(name = "perfil")
@SequenceGenerator(name = "sq_perfil", sequenceName = "sq_perfil", allocationSize = 1, initialValue = 1)
public class Perfil implements Entidade {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sq_perfil")
	@Column(name = "id_perfil")
	private Long idPerfil;

	@Column(name = "nm_perfil")
	private String nmPerfil;

	@ManyToMany
	@Cascade(value = CascadeType.SAVE_UPDATE)
	@JoinTable(name = "perfil_menu", joinColumns = { @JoinColumn(name = "id_perfil") }, inverseJoinColumns = { @JoinColumn(name = "id_menu") })
	private List<Menu> menus;

	@OneToMany(mappedBy = "perfil")
	private List<Usuario> usuarios;

	public Serializable getIdentificador() {
		return getIdPerfil();
	}

	public Long getIdPerfil() {
		return this.idPerfil;
	}

	public void setIdPerfil(Long idPerfil) {
		this.idPerfil = idPerfil;
	}

	public String getNmPerfil() {
		return this.nmPerfil;
	}

	public void setNmPerfil(String nmPerfil) {
		this.nmPerfil = nmPerfil;
	}

	public List<Menu> getMenus() {
		return this.menus;
	}

	public void setMenus(List<Menu> menus) {
		this.menus = menus;
	}

	public List<Usuario> getUsuarios() {
		return this.usuarios;
	}

	public void setUsuarios(List<Usuario> usuarios) {
		this.usuarios = usuarios;
	}

}